﻿using System;
using System.Text;
namespace SmartHRMS.Model
{
   public class CommonFields
    {
       public Guid InsertedBy { get; set; }
       public string InsertedDate { get; set; }
       public Guid UpdatedBy { get; set; }
       public string UpdatedDate { get; set; }
        
       public CommonFields()
        {
            // Default Constructor required for NHibernate
        }

       public CommonFields(Guid insertedBy, string insertedDate, Guid updatedBy, string updatedDate)
        {
            this.InsertedBy = insertedBy;
            this.InsertedDate = insertedDate;
            this.UpdatedBy = updatedBy;
            this.UpdatedDate = updatedDate;		
            validate();
        }

       public CommonFields(Guid updatedBy, string updatedDate)
       {
           this.UpdatedBy = updatedBy;
           this.UpdatedDate = updatedDate;
           validate();
       }
		
        protected virtual void validate()
        {
            StringBuilder sbBrokenRules = new StringBuilder();

            if (this.InsertedBy== Guid.Empty)
            {
                sbBrokenRules.AppendLine("The system is confusing with current authenticated user.Please login again to keep a new record to the databse.");
            }
          
        }
    }
}
